\<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>菜单管理</title>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#inputForm").validate({
				submitHandler: function (form) {
					form.submit();
				},
				errorClass: 'validation-invalid-label',
				highlight: function(element, errorClass) {
					$(element).removeClass(errorClass);
				},
				errorPlacement: function (error, element) {
					validateErrorPlacement(error, element);
				}
			});
			layui.use(function(){
				let form = layui.form;
				form.on('radio(radio-filter-type)', function(data){
					if(data.elem.value == '3'){
						$("input[name='isShow'][value='1']").removeAttr("checked");
						$("input[name='isShow'][value='1']").prop("disabled",true);
						$("input[name='isShow'][value='0']").prop("checked",true);
					}else {
						$("input[name='isShow'][value='1']").prop("checked",true);
						$("input[name='isShow'][value='1']").removeAttr("disabled");
						$("input[name='isShow'][value='0']").removeAttr("checked");
					}
					form.render('radio');
				});
			});
		});
	</script>
</head>
<body>
<div class="content">
	<div class="card">
		<div class="card-body">
			<form:form id="inputForm" method="post" cssClass="layui-form" target="mainFrame"
					   modelAttribute="menu" action="${ctxAdmin}/sys/menu/save"  >
				<form:hidden path="id"/>
				<sys:message content="${message}"/>
				<div class="form-group row">
					<label class="col-sm-3 col-form-label">上级菜单</label>
					<div class="col-sm-8">
						<sys:treeselect id="menu" name="parent.id" value="${menu.parent.id}" labelName="parent.name" labelValue="${menu.parent.name}"
										title="菜单" url="/sys/menu/treeData" extId="${menu.id}" cssClass="required"/>
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 col-form-label">名称</label>
					<div class="col-sm-8">
						<form:input path="name" htmlEscape="false" maxlength="50" cssClass="required form-control"/>
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 col-form-label">类型</label>
					<div class="col-sm-8">
						<div class="layui-form">
							<c:forEach items="${fns:getDictList('sys_menu_type')}" var="dict" varStatus="status">
								<input type="radio" name="type" value="${dict.value}" title="${dict.label}"
									   lay-filter="radio-filter-type" ${dict.value eq menu.type ? 'checked' : ''}>
							</c:forEach>
						</div>
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 col-form-label">显示</label>
					<div class="col-sm-8">
						<div class="layui-form">
							<c:forEach items="${fns:getDictList('show_hide')}" var="dict" varStatus="status">
								<input type="radio" name="isShow" value="${dict.value}" title="${dict.label}" ${dict.value eq menu.isShow ? 'checked' : ''}>
							</c:forEach>
						</div>
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 col-form-label">链接</label>
					<div class="col-sm-8">
						<form:input path="href" htmlEscape="false" maxlength="2000" cssClass="form-control"
									value="${not empty menu.href ? menu.href:'#'}"/>
						<span class="help-inline">点击菜单跳转的页面</span>
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 col-form-label">目标</label>
					<div class="col-sm-8">
						<form:input path="target" htmlEscape="false" maxlength="10" cssClass="form-control"
									value="${not empty menu.target ? menu.target:'mainFrame'}"/>
						<span class="help-inline">链接地址打开的目标窗口，默认：mainFrame</span>
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 col-form-label">排序</label>
					<div class="col-sm-8">
						<form:input path="sort" htmlEscape="false" maxlength="50" cssClass="form-control required digits" />
					</div>
				</div>


				<div class="form-group row">
					<label class="col-sm-3 col-form-label">权限标识</label>
					<div class="col-sm-8">
						<form:input path="permission" htmlEscape="false" maxlength="100" cssClass="form-control"/>
						<span class="help-inline">控制器中定义的权限标识，如：@RequiresPermissions("权限标识")</span>
					</div>
				</div>
				<div class="form-group row">
					<div class="col-sm-9 ml-auto">
						<shiro:hasPermission name="sys:menu:edit">
							<button type="submit" class="btn btn-primary"><i class="icon-database-check mr-2"></i>保 存</button>
						</shiro:hasPermission>
						<button type="button" class="btn btn-light" onclick="cancelSelect()" ><i class="icon-database-arrow mr-2"></i>取 消</button>
					</div>
				</div>
			</form:form>
		</div>
	</div>
</div>
</body>
</html>